package org.thread.test04.demo05;

/**
 *
 *  @author ZJL
 *  @date 2025-03-11
 */public class MyThread extends Thread {
     private String threadName;
     public MyThread() {

     }
     public MyThread(String threadName) {
         this.threadName = threadName;
     }
    @Override
    public void run() {
         while (true) {
             System.out.println("逻辑代码");
             boolean flag = Thread.currentThread().isInterrupted();
//             System.out.println("非阻塞"+flag);
             if (flag) {
                 System.out.println("收尾工作...");
                 break;
             }
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException e) {
//                 System.out.println("睡眠被中断的线程："+Thread.currentThread().isInterrupted());
                 Thread.currentThread().interrupt();
             }
        }
    }
}
